package main

import (
	"encoding/json"
	"fmt"
)

type storageInfo struct {
	Adapter      adapterInfo   `json:"adapter"`
	LogicalInfos []logicalInfo `json:"logical_info"`
}

type adapterInfo struct {
	Status      int64  `json:"status"`
	DataValid   int64  `json:"data_valid"`
	HbaFalg     int64  `json:"hba_flag"`
	Type        string `json:"type"`
	Serial      string `json:"serial"`
	DDRSize     string `json:"ddr_size"`
	SubsysStat  string `json:"subsys_stat"`
	CapStat     string `json:"cap_stat"`
	CapPerc     string `json:"cat_perc"`
	FirmwareVer string `json:"firmware_ver"`
	Wwn         string `json:"wwn"`
}

type logicalInfo struct {
	DevNo           int64            `json:"dev_no"`
	Status          string           `json:"status"`
	Type            string           `json:"type"`
	Capacity        string           `json:"capacity"`
	NonDisPhysInfos []NonDisPhysInfo `json:"nondis_phys_info"`
}

type NonDisPhysInfo struct {
	ConnectionId int64  `json:"connection_id"`
	DevNo        int64  `json:"dev_no"`
	Status       string `json:"status"`
	Type         string `json:"type"`
	Capacity     string `json:"capacity"`
	Vendor       string `json:"vendor"`
	Serial       string `json:"serial"`
	RevisionLv   string `json:"revision_lv"`
	Panel        string `json:"panel"`
	BiosPhysNo   int64  `json:"bios_phys_no"`
	OsPhysNo     int64  `json:"os_phys_no"`
	SlotPhysNo   int64  `json:"slot_phys_no"`
	ProductId    string `json:"product_id"`
	Location     string `json:"location"`
}

func ParseHdmStorgeApi() {
	respBody := "{\n\"adapter\":\n { \n\"status\": 0, \n\"data_valid\": 0, \n\"hba_flag\": 0, \n\"type\": \"\", \n\"serial\": \"\", \n\"ddr_size\": \"\", \n\"subsys_stat\": \"\", \n\"cap_stat\": \"\", \n\"cap_perc\": \"\", \n\"firmware_ver\": \"\", \n\"wwn\": \"\" }, \n\"logical_info\": [ ], \n\"dis_phys_info\": [ ], \n\"cc\": 0 \n}"
	info := storageInfo{}
	respBody = ""
	err := json.Unmarshal([]byte(respBody), &info)
	if err != nil {
		fmt.Println(err.Error())
	}
	fmt.Println(info)
}
